﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NUS.ISS.ARS.BusinessEntity;
using NUS.ISS.ARS.Web.Helper;

namespace NUS.ISS.ARS.Web.UserControls
{
    public partial class PassengerInfoUserControl : System.Web.UI.UserControl
    {
        public int Type
        {
            get
            {
                return Int32.Parse(ddlTitle.SelectedValue);
            }
            set
            {
                ddlTitle.SelectedValue = value.ToString();
            }
        }

        public string GivenName
        {
            get
            {
                return txtGivenName.Text.Trim();
            }
            set
            {
                txtGivenName.Text = value;
            }
        }

        public string SurName
        {
            get
            {
                return txtSurName.Text.Trim();
            }
            set
            {
                txtSurName.Text = value;
            }
        }

        public string PassportNumber
        {
            get
            {
                return txtPassport.Text.Trim();
            }
            set
            {
                txtPassport.Text = value;
            }
        }

        public DateTime DayOfBirth
        {
            get
            {
                return calDateOfBirth.SelectedDate;
            }
            set
            {
                calDateOfBirth.SelectedDate = value;
                txtDayOfBirth.Text = PageHelper.FormatDateTimeDefault(calDateOfBirth.SelectedDate);
            }
        }

        public DateTime PassportExpiryDate
        {
            get
            {
                return calPassportExpiryDate.SelectedDate;
            }
            set
            {
                calPassportExpiryDate.SelectedDate = value;
                txtPassportExpiryDate.Text = PageHelper.FormatDateTimeDefault(calPassportExpiryDate.SelectedDate);
            }
        }

        public int CountryId
        {
            get
            {
                return Int32.Parse(ddlNationality.SelectedValue);
            }
            set
            {
                ddlNationality.SelectedValue = value.ToString();
            }
        }


        public List<Country> Countries
        {
            set
            {
                ddlNationality.DataSource = value;
                ddlNationality.DataTextField = "CountryName";
                ddlNationality.DataValueField = "CountryId";
                ddlNationality.DataBind();
            }
        }

        protected void imbDateOfBirth_Click(object sender, ImageClickEventArgs e)
        {
            calDateOfBirth.Visible = true;
        }

        protected void imgPassportExpiryDate_Click(object sender, ImageClickEventArgs e)
        {
            calPassportExpiryDate.Visible = true;
        }

        protected void calDateOfBirth_SelectionChanged(object sender, EventArgs e)
        {
            txtDayOfBirth.Text = PageHelper.FormatDateTimeDefault(calDateOfBirth.SelectedDate);
            calDateOfBirth.Visible = false;
        }

        protected void calPassportExpiryDate_SelectionChanged(object sender, EventArgs e)
        {
            txtPassportExpiryDate.Text = PageHelper.FormatDateTimeDefault(calPassportExpiryDate.SelectedDate);
            calPassportExpiryDate.Visible = false;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

    }
}